import Vue from 'vue'
import VueRouter from 'vue-router'
// import noFound from '@/components/404'
import bbsMsg from '@/components/bbs/bbsMsg'
import index from '@/components/component/index/index' // 首页
import testStore from '@/components/store' // 测试vuex
import cart from '@/components/user/cart/cart' // 购物车
import OrderConfirm from '@/components/user/order/confirm'
import loginCallback from '@/components/user/loginCallback' // 登陆跳转
import payOrder from '@/components/user/pay/payOrder' // 支付页面
import payCancel from '@/components/user/pay/payCancel' //取消支付
import payOk from '@/components/user/pay/payOk' //取消支付
import framedEdit from '@/components/framed/framedEdit' //框画编辑
import posterEdit from '@/components/poster/posterEdit' //海报编辑
import citiehuaEdit from '@/components/citiehua/citiehuaEdit' //磁铁画编辑
import albumSelect from '@/components/album/albumSelect'
import tlEdit from '@/components/bbs/tlEdit' //台历编辑
import hejiEdit from '@/components/bbs/hejiEdit' //合集编辑
import gualiEdit from '@/components/bbs/gualiEdit' //挂历编辑
import maxImgEdit from '@/components/bbs/bbsImgEdit' //多图编辑的入口

import huaceEdit from '@/components/bbs/huaceEdit' //画册编辑
import travelEdit from '@/components/bbs/lvxingjiEdit' //旅行记编辑
import biyejiEdit from '@/components/bbs/biyejiEdit' //毕业季编辑
import qixishuEdit from '@/components/bbs/qixishuEdit' //遇见情缘编辑
import workNull from '@/components/component/workNull/workNull' //旅行记编辑
import shiguangjiEdit from '@/components/bbs/shiguangjiEdit' //时光集编辑
import jiashuEdit from '@/components/bbs/jiashuEdit' //时光集编辑

import register from '@/components/user/register/registerView' //注册
import login from '@/components/user/login/loginView' //注册
import findPassword from '@/components/user/findPassword/findPassword' //注册

Vue.use(VueRouter)
let router = new VueRouter({
  mode: 'history',
  routes: [{ // 注册
    path: '/user/register/register',
    name: 'register',
    component: register,
    meta: {
      title: '注册'
    }
  }, { // 登录
    path: '/user/login/login',
    name: 'login',
    component: login,
    meta: {
      title: '登录'
    }
  }, { // 找回密码
    path: '/user/findPassword/findPassword',
    name: 'findPassword',
    component: findPassword,
    meta: {
      title: '找回密码'
    }
  }, {
    path: '/album/imgEditMsg',
    name: 'imgEditMsg',
    component: bbsMsg,
    meta: {
      title: '雅昌影像-艺术小时光制作照片书定制,摄影作品出版-传给雅昌专业定制'
    }
  }, {
    path: '/album/maxImgEdit',
    name: 'maxImgEdit',
    component: maxImgEdit,
    meta: {
      title: '小时光编辑'
    }
  }, { // vuex的具体使用路由暂时备份
    path: '/testStore',
    name: 'testStore',
    component: testStore
  }, {
    path: '/user/cart',
    name: 'cart',
    component: cart,
    meta: {
      title: '购物车'
    }
  }, {
    path: '/order/confirm',
    name: 'orderConfirm',
    component: OrderConfirm,
    meta: {
      title: '确认订单'
    }
  }, {
    path: '/user/loginCallback',
    name: 'loginCallback',
    component: loginCallback,
    meta: {
      title: '登陆'
    }
  }, {
    path: '/pay/payOrder',
    name: 'payOrder',
    component: payOrder,
    meta: {
      title: '支付'
    }
  }, {
    path: '/pay/payOk',
    name: 'payOk',
    component: payOk,
    meta: {
      title: '支付成功'
    }
  }, {
    path: '/framed/framedEdit',
    name: 'framedEdit',
    component: framedEdit,
    meta: {
      title: '框画编辑'
    }
  }, {
    path: '/album/albumSelect',
    name: 'albumSelect',
    component: albumSelect,
    meta: {
      title: '画册选择'
    }
  }, {
    path: '/poster/posterEdit',
    name: 'posterEdit',
    component: posterEdit,
    meta: {
      title: '海报编辑'
    }
  }, {
    path: '/citiehua/citiehuaEdit',
    name: 'citiehuaEdit',
    component: citiehuaEdit,
    meta: {
      title: '磁贴画编辑'
    }
  }, {
    path: '/album/shiguangjiEdit',
    name: 'shiguangjiEdit',
    component: shiguangjiEdit,
    meta: {
      title: '拾光集编辑'
    }
  }, {
    path: '/album/tlEdit',
    name: 'tlEdit',
    component: tlEdit,
    meta: {
      title: '台历编辑'
    }
  }, {
    path: '/album/huaceEdit',
    name: 'huaceEdit',
    component: huaceEdit,
    meta: {
      title: '画册编辑'
    }
  }, {
    path: '/album/hejiEdit',
    name: 'hejiEdit',
    component: hejiEdit,
    meta: {
      title: '合集编辑'
    }
  }, {
    path: '/album/travelEdit',
    name: 'travelEdit',
    component: travelEdit,
    meta: {
      title: '旅行记编辑'
    }
  }, {
    path: '/album/qixishuEdit',
    name: 'qixishuEdit',
    component: qixishuEdit,
    meta: {
      title: '遇见.情缘编辑'
    }
  }, {
    path: '/album/biyejiEdit',
    name: 'biyejiEdit',
    component: biyejiEdit,
    meta: {
      title: '毕业季编辑'
    }
  }, {
    path: '/album/gualiEdit',
    name: 'gualiEdit',
    component: gualiEdit,
    meta: {
      title: '挂历编辑'
    }
  }, {
    path: '/album/jiashuEdit',
    name: 'jiashuEdit',
    component: jiashuEdit,
    meta: {
      title: '家书编辑'
    }
  }, {
    path: '/album/workNull',
    name: 'null',
    component: workNull,
    meta: {
      title: 'null'
    }
  }, {
    path: '/',
    beforeEnter: function () {
      location.href = '/welcome.html'
    }
  }]
})

router.afterEach((to, from, next) => {
  console.log(from)
  console.log(to)
  if (to.meta.title) {
    window.document.title = to.meta.title
  }
})

export default router
